package _0_语法._3_分支;

import java.util.Scanner;

public class _11_逆序输出数字 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int num;
        int wan;    // 万位上的数
        int qian;   // 千位上的数
        int bai;    // 百位上的数
        int shi;    // 十位上的数
        int ge;     // 个位
        System.out.println("请输入一个不多于5位的正整数：");
        num = scanner.nextInt();


        if(num / 10000 > 0){
            System.out.println("5位数");
            wan = num / 10000;
            qian = num / 1000 % 10;
            bai = num / 100 % 10;
            shi = num / 10 % 10;
            ge = num % 10;
            System.out.println("倒序后：" + ge + shi + bai + qian + wan);
        } else if (num / 1000 > 0) {
            System.out.println("4位数");
            qian = num / 1000 % 10;
            bai = num / 100 % 10;
            shi = num / 10 % 10;
            ge = num % 10;
            System.out.println("倒序后：" + ge + shi + bai + qian);
        } else if (num / 100 > 0) {
            System.out.println("3位数");
            bai = num / 100 % 10;
            shi = num / 10 % 10;
            ge = num % 10;
            System.out.println("倒序后：" + ge + shi + bai);
        } else if (num / 10 > 0) {
            System.out.println("2位数");
            shi = num / 10 % 10;
            ge = num % 10;
            System.out.println("倒序后：" + ge + shi);
        } else {
            System.out.println("1位数");
            ge = num % 10;
            System.out.println("倒序后：" + ge);
        }
    }
}
